<template>
	<view style="padding-bottom: 400rpx;">
		<uni-search-bar @input="search" placeholder="搜索商户名称" bgColor="#fff" />
		<view :url="'/pages/manage/storeInfo/storeInfo?id='+item.id+'&type=2'" hover-class="none" class="list"
			v-for="(item,index) in list" :key="index">
			<view class="list-info1 flex align between">
				<image :src="item.logo"></image>
				<view class="info1-info">
					<view>{{item.name}}</view>
					<view>法人：{{item.juridical_person}}</view>
					<view>地区：{{item.region_name}}</view>
				</view>
				
			</view>
			<view class="list-info2 flex align">
				<view class="price" @click="toUrl(item.id)">查看成本</view>
				<view class="price" @click="toEdit(item.id)">编辑商户</view>
			</view>
			<!-- <view class="list-info2 flex align between">
				<view class="nums">
					合作说明
				</view>
				<view class="nums">
					跟进进度
				</view>
				<view class="nums">
					合同照片
				</view>
				<view class="nums">
					查看素材
				</view>
			</view> -->
		</view>
		<uni-load-more :status="status" v-if="!empty" :content-text="loadText"></uni-load-more>
		<xw-empty :isShow="empty" text="暂无数据" textColor="#777777"></xw-empty>
		<navigator url="/pages/manage/storeInfo/storeInfo?type=1" class="btns" hover-class="none">添加商户</navigator>
	</view>
</template>

<script>
	import {
		storeList
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				name: '',
				totalPage: 1,
				page: 0,
				offset: 10,
				list: [],
				scrollTop: 0,
				empty: false,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
			};
		},
		onLoad() {},
		onShow() {
			this.page = 0
			this.list = []
			this.getlist()
		},
		onPageScroll(e) {
			const that = this;
			that.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			const that = this;
			that.getlist();
		},
		methods: {
			toEdit(id){
				uni.navigateTo({
					url:'/pages/manage/storeInfo/storeInfo?id='+id+'&type=2'
				})
			},
			toUrl(id){
				uni.navigateTo({
					url:'/pages/manage/payLog?id='+id
				})
			},
			search(e) {
				this.name = e
				this.page = 0
				this.list = []
				this.getlist();
			},
			async getlist() {
				const that = this;
				const {
					totalPage,
					page,
					offset,
					list,
					name,
					act
				} = that;
				let obj = {
					size: offset,
					page: page + 1,
					name
				};
				that.status = 'loading';
				if (totalPage > page) {
					let result = await storeList(obj);
					if (result.code == 1) {
						that.page = page + 1;
						if (result.data.total == 0) {
							console.log((888))
							that.empty = true;
							that.status = 'nomore';
							return;
						}
						that.empty = false;
						setTimeout(() => {
							that.status = 'loadmore';
						}, 500);
						that.list = list.concat(result.data.list);
						that.totalPage = Math.ceil(result.data.total / offset);
					}
				} else {
					setTimeout(() => {
						that.status = 'nomore';
					}, 500);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.btns {
		background: #FF6543;
		width: 100%;
		line-height: 108rpx;
		font-size: 34rpx;
		font-weight: bold;
		text-align: center;
		bottom: 0;
		left: 0;
		color: white;
		position: fixed;
	}

	.list {
		margin: 24rpx;
		padding-bottom: 23rpx;
		background: white;
		border-radius: 12rpx;

		.list-info1 {
			padding: 30rpx;
			border-bottom: solid 1rpx gainsboro;

			image {
				width: 138rpx;
				height: 138rpx;
				border-radius: 12rpx;
			}

			.info1-info {
				margin-left: 20rpx;
				color: #AAAAAA;
				font-size: 26rpx;
				width: 70%;

				view:nth-child(1) {
					font-size: 36rpx;
					font-weight: bold;
					color: #2D2D2D;
					margin-bottom: 11rpx;
				}
			}

		
		}

		.list-info2 {
			padding-top: 12rpx;
			margin: 10rpx 12rpx;
			justify-content: space-around;
			.price {
				background: #FF6543;
				font-size: 28rpx;
				font-weight: bold;
				color: white;
				width: 144rpx;
				height: 63rpx;
				line-height: 63rpx;
				text-align: center;
				border-radius: 12rpx;
			}
		}
	}
</style>